package com.cndw.kungfu.model.battle;

import java.util.List;

import com.cndw.kungfu.domain.Monster;
import com.cndw.kungfu.domain.MonsterAi;
import com.cndw.kungfu.ext.NumberProcesser;
import com.cndw.kungfu.model.Context;
import com.cndw.kungfu.vo.battlevo.BattleMonsterVO;

/**
 * 怪物战斗对象
 * 
 * @author fantadust
 * @date 2011-4-28 下午03:13:32
 */
public class FighterMonster extends FighterBase implements Fighter {

	private Monster sourceObject;
	/**
	 * ai编号标记
	 */
	private int aiSign = 0;

	public FighterMonster(Monster monster) {
		sourceObject = monster;

	}

	@Override
	public long getUniqueId() {
		return sourceObject.getUniqueId();
	}

	@Override
	public String getName() {
		return sourceObject.getName();
	}

	@Override
	public int getHp() {
		return sourceObject.getHp();
	}

	@Override
	public int getMp() {
		return sourceObject.getMp();
	}

	@Override
	public int getMaxHp() {
		return sourceObject.getMaxHp();
	}

	@Override
	public int getMaxMp() {
		return sourceObject.getMaxMp();
	}

	@Override
	public int getLevel() {
		return sourceObject.getLevel();
	}

	@Override
	public int getAttack() {
		return sourceObject.getAttack() + fixAttack;
	}

	@Override
	public int getDefense() {
		return sourceObject.getDefense() + fixDefense;
	}

	@Override
	public int getHit() {
		return sourceObject.getHit() + fixHit;
	}

	@Override
	public int getDodge() {
		return sourceObject.getDodge() + fixDodge;
	}

	@Override
	public int getCrit() {
		return sourceObject.getCrit() + fixCrit;
	}

	@Override
	public int getTough() {
		return sourceObject.getTough() + fixTough;
	}

	@Override
	public Monster getSourceObject() {
		return sourceObject;
	}

	@Override
	public int getSpeed() {
		return sourceObject.getAttackSpeed();
	}

	/**
	 * 设置血量
	 * 
	 * @param alter
	 */
	@Override
	public synchronized void alterHp(int alter) {
		int newHp = NumberProcesser.between(alter + getHp(), 0, getMaxHp());
		// hp = newHp;
		sourceObject.setHp(newHp);
	}

	/**
	 * 设置魔法量
	 * 
	 * @param alter
	 */
	@Override
	public synchronized void alterMp(int alter) {
		int newMp = NumberProcesser.between(alter + getMp(), 0, getMaxMp());
		sourceObject.setMp(newMp);
	}

	@Override
	public int getHurtAdd() {
		return 0;
	}

	@Override
	public int getHurtRemove() {
		return 0;
	}

	@Override
	public int getHurtReflex() {
		return 0;
	}

	@Override
	public int getHurtAbsorb() {
		return 0;
	}

	@Override
	public int getCritAdd() {
		return 0;
	}

	@Override
	public int getSceneId() {
		return 0;
	}

	public List<AiAction> getAiActions() {
		if (sourceObject.getAi() > 0) {
			MonsterAi monsterAi = Context.getUndercityServer().getMonsterAi(sourceObject.getAi());
			if (monsterAi != null) {
				return monsterAi.getAiActions();
			}
		}
		return null;
	}

	public boolean isSignAi(int aid) {
		return (aiSign & aid) > 0;
	}

	public void aiSignAdd(int aid) {
		aiSign = aiSign | aid;
	}

	public void aiSignSet(int aid) {
		aiSign = aid;
	}

	@Override
	public BattleMonsterVO toVO() {
		return new BattleMonsterVO(this);
	}

	@Override
	public int getScoreCHK() {
		return 0;
	}

	@Override
	public int getHurtCoffAdd() {
		return 0;
	}

	@Override
	public int getHurtCoffRemove() {
		return 0;
	}

}
